<template>
  <el-main class="match-index" :style="{ overflow: 'auto' }">
    <div class="matchend-success-container">
      <div class="matchend-success-title">提交成功</div>
      <div class="matchend-success-icon-wrap">
        <div class="matchend-success-icon">
          <span class="matchend-success-check">&#10003;</span>
        </div>
      </div>
      <div class="matchend-success-tip">感谢您的提交！</div>
      <div class="matchend-success-desc">
        <span v-html="infoContext"></span>
      </div>
      <el-button class="matchend-success-btn" type="primary" @click="goHome">关闭</el-button>
    </div>
  </el-main>
</template>

<script setup lang="ts">
import { computed, toRefs } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();
const p = withDefaults(defineProps<{ time: any, match: any, statematch: "开始" | "结束" }>(), {
  statematch: '开始'
})
const { match } = toRefs(p);

const infoContext = computed(() => {
  try {
    if (!match.value.info) return "";
    if (typeof match.value.info === "string") {
      const obj = JSON.parse(match.value.info);
      return obj?.context || "";
    }
    if (typeof match.value.info === "object" && match.value.info !== null) {
      return match.value.info.context || "";
    }
  } catch {
    return "";
  }
  return "";
});

function goHome() {
  router.push({ name: "首页", query: { activityId: match.value.ID } });
}
</script>

<style scoped>
.match-index {
  padding: 0;
  background: #f6f7fb;
  min-height: 100vh;
}

.matchend-success-container {
  max-width: 360px;
  margin: 60px auto 0 auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
  padding: 32px 24px 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.matchend-success-title {
  font-size: 26px;
  font-weight: bold;
  color: #222;
  margin-bottom: 24px;
  text-align: center;
}

.matchend-success-icon-wrap {
  margin-bottom: 18px;
}

.matchend-success-icon {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 2px solid #409eff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  background: #f8fafd;
}

.matchend-success-check {
  font-size: 54px;
  color: #409eff;
  font-weight: bold;
  line-height: 1;
}

.matchend-success-tip {
  margin: 18px 0 10px 0;
  color: #222;
  font-size: 16px;
  font-weight: 500;
  text-align: center;
}

.matchend-success-desc {
  color: #888;
  font-size: 14px;
  margin-bottom: 28px;
  text-align: center;
  line-height: 1.7;
}

.matchend-success-btn {
  width: 120px;
  height: 40px;
  font-size: 16px;
  border-radius: 20px;
  margin: 0 auto;
  display: block;
  background: #409eff;
  border: none;
  color: #fff;
}
</style>